<?php

$__FILEPATH__ = dirname(__FILE__)."/";
require_once($__FILEPATH__."./func_common.php");
require_once($__FILEPATH__."./class_def.php");
require_once($__FILEPATH__."./conf/info.php");
session_start();
if (!isset($_SESSION["user"]))
{
	header("Location: ./loginpage.php");
	exit(0);
}
header("Content-Type: text/html; charset=UTF-8");

if (!isset($_GET["bid"]))
	die("操作非法");

$BID = intval($_GET["bid"]);
$mysqli = GetMysqliInstance();

$result = $mysqli->query("select user from bloglist where id = $BID");
if ($result && ($row = $result->fetch_array(MYSQLI_ASSOC)) && ($row["user"] == $_SESSION["user"] || isset($_SESSION["admin"]))) 
	$result->close();
else 
{
	$result->close();
	$mysqli->close();
	die("非法操作~");
}


$mysqli->query("update classlist set cnt = cnt - 1 where id in (select cid from bclinklist where bid = $BID)");
$mysqli->query("delete from bclinklist where bid = $BID");
$mysqli->query("delete from bloglist where id = $BID");
$mysqli->query("delete from msglist where bid = $BID");
$mysqli->close();


header("Location: ../blog_home.php");

?>